<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .father {
            position: relative;
            width: 200px;
            height: 180px;
            background-color: skyblue;
            border: 2px solid red;
            padding: 5px;
            margin: 150px;
        }

        .son {
            width: 100px;
            height: 100px;
            background-color: purple;
            margin-left: 45px;
        }

        .janna {
            height: 200px;
            background-color: skyblue;
            margin: 0 auto 200px;
            padding: 10px;
            border: 15px solid red;
            /* width: 300px; */
        }
    </style>
</head>

<body>
    <div class="father">father
        <div class="son">son</div>
    </div>
    <div class="janna">娜迦</div>

    <script>
        /* 
        轮播图的移动： 当前距离 + 若干像素， 重新赋值
     
        offset      抵消  ， 弥补，  补偿 

        1. offsetLeft：元素左侧的偏移量
        2. offsetTop： 元素上侧的偏移量
        3. offsetLeft  offsetTop  是以父级为参考物，父级必须有定位，否则就是 body 为参考系
        4. 没有 右侧和 下侧 的 偏移量
        
        5. offsetWidth = width + border + padding
        6. offsetheight = height + border + padding
        7. offsetWidth 可以动态的获取元素的尺寸
        8. offsetParent 获取有父级定位的元素节点
    */

        let father = document.querySelector('.father');
        let son = document.querySelector('.son');

        console.log(father.offsetLeft); // 150
        console.log(father.offsetTop); //  150 
        console.log('------son-----------------------');
        console.log(son.offsetLeft); //  50
        console.log(son.offsetTop); //  26

        console.log(father.offsetWidth); //  214 
        console.log(father.offsetHeight); // 194

        console.log('-------------janna----------------');
        let janna = document.querySelector('.janna');
        console.log(janna.offsetWidth); // 1519 

        console.log(son.parentNode);
        console.log(son.offsetParent);
    </script>
</body>

</html>